
import { config } from '@/utils/requestconfig'
// 基础字段
export const basicComponents = [
  {
    type: 'input',
    icon: 'icon-input',
    name: '单行文本',
    model: '',
    options: {
      width: '100%',
      required: false,
      dataType: 'string',
      pattern: '',
      placeholder: '请输入单行文本',
      disabled: false
    }
  },
  {
    type: 'textarea',
    icon: 'icon-diy-com-textarea',
    name: '多行文本',
    model: '',
    options: {
      width: '100%',
      required: false,
      disabled: false,
      pattern: '',
      placeholder: '请输入多行文本'
    }
  },
  {
    type: 'number',
    icon: 'icon-number',
    name: '计数器',
    model: '',
    options: {
      width: '',
      required: false,
      defaultValue: 0,
      min: '',
      max: '',
      step: 1,
      disabled: false,
      controlsPosition: ''
    }
  },
  {
    type: 'radio',
    icon: 'icon-radio-active',
    name: '单选框组',
    model: '',
    options: {
      inline: true,
      defaultValue: '',
      showLabel: false,
      options: [
        {
          value: 'Option 1',
          label: '选项 1'
        },
        {
          value: 'Option 2',
          label: '选项 2'
        },
        {
          value: 'Option 3',
          label: '选项 3'
        }
      ],
      required: false,
      width: '',
      remote: false,
      remoteOptions: [],
      props: {
        value: 'value',
        label: 'label'
      },
      remoteFunc: '',
      disabled: false
    }
  },
  {
    type: 'checkbox',
    icon: 'icon-check-box',
    name: '多选框组',
    model: '',
    options: {
      inline: true,
      defaultValue: [],
      showLabel: false,
      options: [
        {
          value: '选项 1'
        },
        {
          value: '选项 2'
        },
        {
          value: '选项 3'
        }
      ],
      required: false,
      width: '',
      remote: false,
      remoteOptions: [],
      props: {
        value: 'value'
      },
      remoteFunc: '',
      disabled: false
    }
  },
  {
    type: 'time',
    icon: 'icon-time',
    name: '时间选择器',
    model: '',
    options: {
      defaultValue: '00:00:00',
      readonly: false,
      disabled: false,
      editable: true,
      clearable: true,
      placeholder: '',
      startPlaceholder: '',
      endPlaceholder: '',
      isRange: false,
      arrowControl: true,
      format: 'HH:mm:ss',
      required: false,
      width: ''
    }
  },
  {
    type: 'date',
    icon: 'icon-date',
    name: '日期选择器',
    model: '',
    options: {
      defaultValue: '',
      readonly: false,
      disabled: false,
      editable: true,
      clearable: true,
      placeholder: '',
      startPlaceholder: '',
      endPlaceholder: '',
      type: 'date',
      format: 'yyyy-MM-dd',
      timestamp: false,
      required: false,
      width: ''
    }
  },
  {
    type: 'text',
    icon: 'icon-wenzishezhi-',
    name: '文字',
    options: {
      defaultValue: '这是文字内容',
      customClass: ''
    }
  },
  {
    type: 'imgupload',
    icon: 'icon-tupian',
    name: '图片/文件',
    model: '',
    options: {
      defaultValue: [],
      required: false,
      size: {
        width: 100,
        height: 100
      },
      width: '',
      tokenFunc: 'funcGetToken',
      token: '',
      disabled: false,
      length: 8,
      multiple: false,
      isQiniu: false,
      isDelete: true,
      min: 0,
      isEdit: false,
      action: config.uploadurl + 'upload/UploadFile'
    }
  },
  {
    type: 'select',
    icon: 'icon-select',
    name: '下拉选择框',
    options: {
      defaultValue: '',
      multiple: false,
      disabled: false,
      clearable: false,
      placeholder: '',
      required: false,
      showLabel: false,
      width: '',
      options: [
        {
          label: '选项 1',
          value: '选项 1'
        },
        {
          label: '选项 2',
          value: '选项 2'
        }, {
          label: '选项 3',
          value: '选项 3'
        }
      ],
      remote: false,
      filterable: false,
      remoteOptions: [],
      props: {
        value: 'value'
      },
      remoteFunc: ''
    }
  },
  {
    type: 'grid',
    icon: 'icon-grid-',
    name: '栅格布局',
    columns: [
      {
        span: 12,
        list: []
      },
      {
        span: 12,
        list: []
      }
    ],
    options: {
      gutter: 0,
      justify: 'start',
      align: 'top'
    }
  }
  // {
  //   type: 'color',
  //   icon: 'icon-color',
  //   options: {
  //     defaultValue: '',
  //     disabled: false,
  //     showAlpha: false,
  //     required: false
  //   }
  // },
  // {
  //   type: 'switch',
  //   icon: 'icon-switch',
  //   options: {
  //     defaultValue: false,
  //     required: false,
  //     disabled: false
  //   }
  // },
  // {
  //   type: 'slider',
  //   icon: 'icon-slider',
  //   options: {
  //     defaultValue: 0,
  //     disabled: false,
  //     required: false,
  //     min: 0,
  //     max: 100,
  //     step: 1,
  //     showInput: false,
  //     range: false,
  //     width: ''
  //   }
  // },
  // {
  //   type: 'rate',
  //   icon: 'icon-pingfen1',
  //   options: {
  //     defaultValue: null,
  //     max: 5,
  //     disabled: false,
  //     allowHalf: false,
  //     required: false
  //   }
  // }
]

export const advanceComponents = [
  // {
  //   type: 'blank',
  //   icon: 'icon-zidingyishuju',
  //   options: {
  //     defaultType: 'String'
  //   }
  // },
  // {
  //   type: 'imgupload',
  //   icon: 'icon-tupian',
  //   options: {
  //     defaultValue: [],
  //     size: {
  //       width: 100,
  //       height: 100
  //     },
  //     width: '',
  //     tokenFunc: 'funcGetToken',
  //     token: '',
  //     domain: 'http://pfp81ptt6.bkt.clouddn.com/',
  //     disabled: false,
  //     length: 8,
  //     multiple: false,
  //     isQiniu: false,
  //     isDelete: false,
  //     min: 0,
  //     isEdit: false,
  //     action: 'https://jsonplaceholder.typicode.com/photos/'
  //   }
  // },
  // {
  //   type: 'editor',
  //   icon: 'icon-fuwenbenkuang',
  //   options: {
  //     defaultValue: '',
  //     width: ''
  //   }
  // },
  // {
  //   type: 'cascader',
  //   icon: 'icon-jilianxuanze',
  //   options: {
  //     defaultValue: [],
  //     width: '',
  //     placeholder: '',
  //     disabled: false,
  //     clearable: false,
  //     remote: true,
  //     remoteOptions: [],
  //     props: {
  //       value: 'value',
  //       label: 'label',
  //       children: 'children'
  //     },
  //     remoteFunc: ''
  //   }
  // }
]
// /布局组件 声明
export const layoutComponents = [
  // {
  //   type: 'grid',
  //   icon: 'icon-grid-',
  //   name: '栅格布局',
  //   columns: [
  //     {
  //       span: 12,
  //       list: []
  //     },
  //     {
  //       span: 12,
  //       list: []
  //     }
  //   ],
  //   options: {
  //     gutter: 0,
  //     justify: 'start',
  //     align: 'top'
  //   }
  // }
]
/** 字段说明
 * type  字段类型 自定义   必须字段
 * icon 图标
 * name 字段名称           必须字段
 * isChoose 是否选择
 * model 对应后端的字段 一般不能重复    必须字段
 * issys
 * key 字段的key 防止重复                必须字段
 * ishidden 是否隐藏 不在表单中显示字段 一般是计算列时隐藏     必须字段
 * options {
 *  defaultValue 默认值       必须字段
 *  multiple 是否多选
 *  disabled 是否禁用          必须字段
 *  clearable 清空操作
 *  required 必填              必须字段
 *  showLabel 是否显示标签
 *  dataType 数据类型           必须字段
 *  pattern 正则验证            必须字段
 *  placeholder 占位内容
 *  customRule 自定义验证方法      必须字段
 *  remoteFunc 取数据源的方法 一般在基础组件中使用  业务组件 在组件中获取数据源
 *}
 * rules 字段内容验证  必须字段
 * conditionOptions 作为条件时 比较方式
 * objtype 对象类型 后端判断时需要
 */

// 业务组件 声明区域
export const CostomComponents = [
  {
    type: 'selectperson',
    icon: 'icon-select',
    name: '申请人',
    isChoose: false,
    model: 'applyuser',
    issys: true,
    key: '1604991365000-10001',
    options: {
      defaultValue: {},
      multiple: false,
      disabled: false,
      clearable: true,
      required: true,
      dataType: 'Object',
      showLabel: false,
      placeholder: '请选择申请人',
      customRule: 'validateObject'
    },
    rules: [{ message: '申请人必选', required: true }, { validator: 'validateObject', message: '申请人必选' }],
    conditionOptions: [{ label: '属于', value: 'belong' }, { label: '不属于', value: 'notbelong' }],
    objtype: 'personobj'
  },
  {
    type: 'selectdepart',
    icon: 'icon-input',
    name: '申请部门',
    model: 'applydepart',
    issys: true,
    key: '1604991365000-10002',
    options: {
      width: '100%',
      defaultValue: {},
      required: true,
      dataType: 'Object',
      pattern: '',
      placeholder: '请选择申请部门',
      customRule: 'validateObject',
      remoteFunc: '',
      disabled: false
    },
    rules: [{ message: '申请部门必选', required: true }, { validator: 'validateObject', message: '申请部门必选' }],
    conditionOptions: [{ label: '属于', value: 'belong' }, { label: '不属于', value: 'notbelong' }],
    objtype: 'departobj'
  },
  {
    type: 'input',
    icon: 'icon-input',
    name: '报销金额',
    model: 'submitmoney',
    issys: true,
    key: '1604991365000-20003',
    ishidden: false,
    options: {
      width: '100%',
      defaultValue: '',
      required: true,
      dataType: '',
      pattern: '/^(([1-9]{1}\\d*)(\\.\\d{1,2})?)|(0\\.\\d{1,2})$/',
      placeholder: '请输入报销金额',
      disabled: false
    },
    rules: [{ message: '报销金额必填', required: true }, { pattern: '/^(([1-9]{1}\\d*)(\\.\\d{1,2})?)|(0\\.\\d{1,2})$/', message: '报销金额格式不正确', trigger: 'change' }],
    conditionOptions: [{ label: '等于', value: '=' }, { label: '不等于', value: '!=' }, { label: '大于等于', value: '>=' }, { label: '小于等于', value: '<=' }, { label: '大于', value: '>' }, { label: '小于', value: '<' }],
    objtype: 'float'
  },
  {
    type: 'input',
    icon: 'icon-input',
    name: '支付金额',
    model: 'paymoney',
    issys: true,
    key: '1604991365000-40003',
    ishidden: false,
    options: {
      width: '100%',
      defaultValue: '',
      required: true,
      dataType: '',
      pattern: '/^(([1-9]{1}\\d*)(\\.\\d{1,2})?)|(0\\.\\d{1,2})$/',
      placeholder: '请输入支付金额',
      disabled: false
    },
    rules: [
      { message: '支付金额必填', required: true },
      { pattern: '/^(([1-9]{1}\\d*)(\\.\\d{1,2})?)|(0\\.\\d{1,2})$/', message: '支付金额格式不正确', trigger: 'change' }
    ],
    conditionOptions: [{ label: '等于', value: '=' }, { label: '不等于', value: '!=' }, { label: '大于等于', value: '>=' }, { label: '小于等于', value: '<=' }, { label: '大于', value: '>' }, { label: '小于', value: '<' }],
    objtype: 'float'
  },
  {
    type: 'project',
    icon: 'icon-select',
    name: '项目',
    model: 'project',
    key: '1604991365000-50001',
    options: {
      defaultValue: '',
      multiple: false,
      disabled: false,
      clearable: true,
      placeholder: '请选择项目',
      required: false,
      showLabel: false,
      width: '',
      options: [],
      remote: true,
      filterable: true,
      remoteOptions: [],
      props: {
        value: 'Id',
        label: 'ProjectName'
      }
      // remoteFunc: 'searchProject'
    }
  },
  {
    type: 'selectmultperson',
    icon: 'icon-select',
    name: '单位人员',
    isChoose: false,
    model: 'personCustom',
    issys: false,
    key: '1604991365000-50007',
    options: {
      defaultValue: [],
      multiple: false,
      disabled: false,
      clearable: true,
      required: false,
      showLabel: false,
      dataType: 'array',
      customRule: 'validateArray'
    }
  },
  {
    type: 'billbuydetail',
    icon: 'icon-select',
    name: '采购明细',
    isChoose: false,
    model: 'billbuydetail',
    key: '1604991365000-50008',
    options: {
      defaultValue: [],
      multiple: false,
      disabled: false,
      clearable: false,
      required: false,
      dataType: 'array',
      showLabel: false,
      customRule: 'validateBillBuyDetail'
    }
  },
  {
    type: 'billtravelbusiness',
    icon: 'icon-select',
    name: '差旅行程',
    isChoose: false,
    model: 'billtravelbusiness',
    key: '1604991365000-50009',
    options: {
      defaultValue: [],
      multiple: false,
      disabled: false,
      clearable: false,
      required: false,
      dataType: 'array',
      showLabel: false,
      applybilltype: [],
      customRule: 'validateBillTravelBusiness'
    }
  },
  {
    type: 'customarchives',
    icon: 'icon-select',
    name: '自定义档案',
    model: 'customarchives',
    key: '1604991365000-50016',
    options: {
      defaultValue: {},
      multiple: false,
      disabled: false,
      clearable: false,
      required: false,
      dataType: 'Object',
      showLabel: false,
      customRule: 'validateObject'
    }
  },
  {
    type: 'textarea',
    icon: 'icon-input',
    name: '事由',
    model: 'particulars',
    issys: false,
    key: '1604991365000-50015',
    options: {
      width: '100%',
      defaultValue: '',
      required: false,
      dataType: 'string',
      pattern: '',
      placeholder: '请输入事由',
      disabled: false
    }
  }
]
